package com.example.liuyuhan


import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView

class PrimeAdapter(private val primeList: List<Int>) : RecyclerView.Adapter<PrimeAdapter.PrimeViewHolder>() {

    class PrimeViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        val primeTextView: TextView = itemView.findViewById(R.id.tvPrime)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PrimeViewHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.item_prime, parent, false)
        return PrimeViewHolder(view)
    }

    override fun onBindViewHolder(holder: PrimeViewHolder, position: Int) {
        holder.primeTextView.text = primeList[position].toString()
    }

    override fun getItemCount(): Int {
        return primeList.size
    }
}
